package org.dromara.common.alarm.config;

import com.cloud.alarm.dinger.config.DingerAutoConfiguration;
import com.cloud.alarm.dinger.support.CustomMessage;
import com.cloud.alarm.dinger.support.InteractiveMessage;
import org.dromara.common.alarm.message.MarkDownMessage;
import org.dromara.common.alarm.message.TextMessage;
import org.dromara.common.core.factory.YmlPropertySourceFactory;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;

import static com.cloud.alarm.dinger.constant.DingerConstant.BeanName.*;

/**
 * 机器人告警配置类
 *
 * @author shuai.zhou
 */
@AutoConfigureBefore(DingerAutoConfiguration.class)
@PropertySource(value = "classpath:common-alarm.yml", factory = YmlPropertySourceFactory.class)
public class AlarmAutoConfiguration {

    /**
     * 默认Text消息格式配置
     *
     * @return CustomMessage
     */
    @Bean(TEXT_MESSAGE_BEAN_NAME)
    public CustomMessage textMessage() {
        return new TextMessage();
    }

    /**
     * 默认markdown消息格式配置
     *
     * @return CustomMessage
     */
    @Bean(MARKDOWN_MESSAGE_BEAN_NAME)
    public CustomMessage markDownMessage() {
        return new MarkDownMessage();
    }

    /**
     * 默认interactive消息格式配置
     *
     * @return CustomMessage
     */
    @Bean(INTERACTIVE_MESSAGE_BEAN_NAME)
    public CustomMessage interactiveMessage() {
        return new InteractiveMessage();
    }

}
